/*

    @子弹
    
*/    


var gap=7;//创建子弹的间隔参数
var gapNum=0;//计量啊子弹间隔参数的数
var bullets=[]; //储存存在的子弹
var isDouble=false;//用于创建双排子弹或者 一排子弹
var isCrowed=false;//用于是否创建密集子弹

function createButtle(){
    
    if (isCrowed){
        gap=3;
    } else {
        gap=7;
    }
    gapNum++;
    if(gapNum%gap==0){
        //创建子弹
        gapNum=0;
        if(isDouble){
            //双排
            var b1=new Buttle(hero.x+9,hero.y+20);
            var b2=new Buttle(hero.x+hero.w-14,hero.y+19);
            bullets.push(b1);
            bullets.push(b2);
        }else {
            //单排
            var b=new Buttle(hero.x+hero.w/2-2,hero.y-14);
            bullets.push(b);
        }
    }
}

function Buttle(x,y){
    this.x=x;
    this.y=y;
    this.w=6;
    this.h=14;
    this.hurt=100;
    this.speed=10;
    this.isDelete=false;
}

Buttle.prototype._move =function(){
    this.y-=this.speed;
    if(this.y<-this.h) {
        this.isDelete=true;
    }
}
Buttle.prototype.draw =function (){
    this._move();
    ctx.beginPath();
    ctx.drawImage(bltImg,this.x,this.y,this.w,this.h);
}







